package com.jh.example;

public class BitNShiftMain 
{

	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{
		int intNums1 = 123;
		int intNums2 = -123;
		
		System.out.printf("%d : %s%n", intNums1, shifts(intNums1));
		System.out.printf("%d : %s%n", intNums1, Integer.toBinaryString(intNums1));
		System.out.printf("%d : %s%n", intNums2, shifts(intNums2));
		System.out.printf("%d : %s%n", intNums2, Integer.toBinaryString(intNums2));
		


		

	}

	//10진수를 2진수 String 으로 변환
	public static String shifts(int a) 
	{
		String s = "";
		int c ;
		for (int i = 0; i < 31; i++) 
		{
			int aa = a%2;
			s=(aa>=0)?(aa+s):(-aa+s);
			a>>=1; 
		}
		
		return s;
	}
}
